package 结构器模式.外观模式;

/**
 * @Description 外观类，主要和该类对象进行交互
 * @Author shallow
 * @Date 2023/3/5 19:22
 */

public class SmartApplicationFacade {
    //聚合电器对象们
    private Light light;
    private TV  tv;
    private AirCondition airCondition;

    public SmartApplicationFacade() {
        light = new Light();
        tv = new TV();
        airCondition = new AirCondition();
    }
    //通过语音控制
    public void say(String message){
        if(message.contains("打开")){
            on();
        }
        else if (message.contains("关闭")){
            off();
        }
        else{
            System.out.println("我听不懂你说的！");
        }
    }
    //一键打开功能
    public void on(){
        light.on();
        tv.on();
        airCondition.on();
    }
    //一键关闭功能
    public void off(){
        light.off();
        tv.off();
        airCondition.off();
    }
}
